-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding usage doc for Natural Language API. #2062
Conversation
and each method uses a `Document`_ for representing text. To | ||
create a :class:`~gcloud.language.document.Document`, | ||
|
||
.. code-block:: python |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
A couple of more general questions:
|
app. You can analyze text uploaded in your request or integrate | ||
with your document storage on Google Cloud Storage. | ||
|
||
This is a Beta release of Google Cloud Natural Language API. This |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tseaver Can you weigh in here on which response values you think we should wrap? |
@jerjou Can you take a look to make sure we have someone who has used the API a bit to comment on usability. |
For for entity in document.analyze_entities():
build_entity_link(entity.name, entity.type, entity.url) For def by_sentiment(document):
"""Sort key: rank from most negative to most positive."""
sentiment = document.analyze_sentiment()
return sentiment.polarity * sentiment.magnitude
ranked = sorted(documents, key=by_sentiment) For only_syntax = document.annotate_text(
include_entities=False, include_sentiment=False)
assert only_syntax.entities is None
assert only_syntax.sentiment is None
tree = ParseTree() # imagined class w/ 'add_token' method.
for index, token in enumerate(only_syntax.tokens):
edge = token.dependency_edge
tree.add_token(
index, token.lemma, token.part_of_speech, edge.head_index, edge.label) |
>>> document = client.document(text_content) | ||
|
||
By default, the document's language and type are English and | ||
plain text: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM. |
cdb4adf
to
d36ad4d
Compare
.. code-block:: python | ||
|
||
>>> client = language.Client(language='es', | ||
... encoding=encoding=language.Encoding.UTF16) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
… be run in cloud shell [(#2062)](GoogleCloudPlatform/python-docs-samples#2062)
/cc @omaray are you in the org yet (I can't assign you to this PR)